require('./PageWorkplan.styl');
const Panel = require('components/panel');
const GirdView = require('components/girdview');
const Menu = require('components/menu');
const DB = require('app/db');
import { Control } from 'react-keeper'
const ui = require('clientConfig/util/jsapi/ui');
var paths = [{ path: "workplan", title: "计划管理", id: 'index0', tabTitles: "计划审批 计划跟踪" }];
class Workplan extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
        };
        this.action = [
            {
                content: '开发类',
                icon: "pay/software.svg",
                path: "/home/workplan/software"
            }, {
                content: '运维类',
                icon: "pay/maintain.svg",
                path: "/home/workplan/software"
            }//, {
            //     content: '系统集成',
            //     icon: "pay/Integrate.svg",
            //     path: "/home/workplan/software"
            // }, {
            //     content: '系统维护',
            //     icon: "pay/maintain.svg",
            //     path: "/home/workplan/software"
            // }
        ];
        if (Control.state){
            if(Control.state.origin_title=="项目进度"){
                this.activenum = 1; 
                paths = [{ path: "workplan", title: "计划管理", id: 'index0', tabTitles: "计划跟踪" }];
            }              
        }else{
            this.activenum = 0;
            paths = [{ path: "workplan", title: "计划管理", id: 'index0', tabTitles: "计划审批 计划跟踪" }];            
        }      
        this.handlePlusClick = this.handlePlusClick.bind(this);
    }
    handlePlusClick() {
        this.setState({
            show: true,
        })
    }

    render() {
        let girdItems = [{ title: "待我审批的", hashPath: "/home/workplan/pending", src: "pending", homesvg: 'workplan0_svg1' }, { title: "我发起的", hashPath: "/home/workplan/sponsored", src: "sponsored", homesvg: "workplan0_svg2" }, { title: "抄送我的", hashPath: "/home/workplan/copy", src: "copy", homesvg: "workplan0_svg3" },
        { title: "变更申请", hashPath: "/home/workplan/changereq", src: "changereq", homesvg: "workplan0_svg4" }, { title: "变更记录", hashPath: "/home/workplan/changerecord", src: "changerecord", homesvg: "workplan0_svg5" }];
        let pro_girdItems = [{ title: "项目总览", hashPath: "/home/workplan/progresstrack", src: "pending", homesvg: 'workplan1_svg1' }, { title: "单个项目", hashPath: "/home/workplan/singleproject", src: "pending", homesvg: "workplan1_svg2" }];
        return (
            <div className="workplan">
                {paths.map((item, index) => {
                    const ContentSvg = require(`images/svg/mangement/${item.path}.svg`);
                    return (
                        <Panel title={item.title} Key={item.path} active activenum={this.activenum} tabTitles={item.tabTitles} cbPlus={this.handlePlusClick}>
                            <ContentSvg className="content-svg"/>
                            {!Control.state && <GirdView girdItems={girdItems} path={item.path} className="t-SMT36"/>}
                            <GirdView girdItems={pro_girdItems} path={item.path} />
                        </Panel>);
                })
                }
                {!window.isBp ? <Menu item={this.action} show={this.state.show} /> : ''}
            </div>
        );
    }

    componentWillMount() {
        ui.setTitle({ title: "IT项目管理信息系统" });
    }

    componentDidMount() {

    }

    componentWillReceiveProps(nextProps) {
    }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {
    }

    componentDidUpdate(prevProps, prevState) {
    }

    componentWillUnmount() {

    }
}

module.exports = Workplan;
